﻿using System.Net;
using System.Text;

using GCC.Container.Abstracts;

namespace System.DeviceServer.MyUDP
{
    public class MyUDPClient : AbsCommUDPClient<byte[]>
    {
        public MyUDPClient(IPEndPoint? localInfo, AbsGCCLogger logger, string name, IPEndPoint? target = null) : base(localInfo, logger, name, target)
        {
        }

        protected override bool CheckHeader(in Memory<byte> headBuffer)
        {
            return true;
        }

        protected override int GetBodyLengh(byte[] data)
        {
            return data.Length;
        }

        protected override byte[] HandleData(in Memory<byte> _, in Memory<byte> bodyBuffer)
        {
            return bodyBuffer.ToArray();
        }

        protected override void PutData(in Memory<byte> headBuffer, Memory<byte> bodyBuffer, in byte[] data)
        {
            data.CopyTo(bodyBuffer.Span);
        }

        protected override void PutHeader(Memory<byte> headBuffer, in byte[] data)
        {
        }
    }
}
